<?php

class Session{
	private static $_instance;
	
	private $_data;
	private function __construct(){
		session_start();
		echo session_id()."\n<br />";
		$this->_data = $_SESSION;
	}
	
	public function __get($name){
		//echo "session__get".$name." ".$_SESSION[$name]." 1\n<br />";
		
		if (isset($this->_data[$name])) {
			return $this->_data[$name];
		}
		return null;
	}
	
	public function __set($name,$value){
		$this->_data[$name]=$value;
	}
	
	public function __destruct(){
		$_SESSION=$this->_data;
		session_commit();
	}
	
	public function commit(){
		//$_SESSION=$this->_data;
		//session_commit();
	}
	
	public static function getInstance(){
		if (Session::$_instance==null) {
			Session::$_instance = new Session();
		}
		return Session::$_instance;
	}
}

?>